<!-- 用户界面头部组件 -->
<template>
  <div>
    <!-- 黑色顶部导航栏 -->
    <div class="top-nav">
      <span class="tagline"></span>
      <nav class="top-nav-links">
        <ul>
          <li><router-link to="/login">登录</router-link></li>
          <li><router-link to="/register">注册</router-link></li>
          <li><router-link to="/MemberCenter">会员中心</router-link></li>
          <li><router-link to="/support">在线客服</router-link></li>
          <li><router-link to="/helpCenter">帮助中心</router-link></li>
        </ul>
      </nav>
    </div>

    <!-- 主标题和右侧功能区 -->
    <header class="main-header">
      <h1>教育平台录播课商城</h1>
      <div class="header-right">
        <input type="text" placeholder="输入关键字进行搜索">
        <button class="search-btn"><i class="fas fa-search"></i></button>
        <div class="cart-icon" @click="goToShoppingCart">
          🛒
          <span class="badge">5</span>
        </div>
      </div>
    </header>
  </div>
</template>

<script setup>
// import { computed } from 'vue'
import { useRouter } from 'vue-router'
// import { useStore } from '@/stores'

const router = useRouter()
// const store = useStore()

// const user = computed(() => store.user)

const logout = () => {
  store.logout()
  router.push('/')
}
const goToShoppingCart = () => {
  router.push('/shoppingCart')
}
</script>

<style scoped>
/* 黑色顶部导航栏 */
.top-nav {
  background-color: #333;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 20px;
  margin-bottom: 0px;
}

.tagline {
  font-size: 14px;
}

.top-nav-links ul {
  list-style: none;
  display: flex;
  gap: 15px;
}

.top-nav-links li a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

/* 主标题和右侧功能区 */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 25px; /* 调整为更合适的值 */
  margin-top: 0; /* 确保顶部间距为 0 */
  background-color: #fff; /* 添加背景颜色 */
}

.main-header h1 {
  font-size: 30px;
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-right input {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 200px;
  font-size: 14px;
}

.search-btn {
  padding: 8px;
  background-color: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-icon {
  position: relative;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-icon .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: red;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}
</style>